package com.etymgiko.spaceshipshop.model;

import javax.persistence.Entity;
import javax.persistence.Table;
import javax.persistence.Column;
import javax.persistence.Id;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.ManyToOne;
import javax.persistence.JoinColumn;
import javax.persistence.Version;
import java.io.Serializable;

/**
 * Spaceship.
 *
 * @author Ivan Holub
 */
@Entity
@Table(name = "STARSHIP")
public class SpaceShip implements Serializable {
    @Column(name = "ID")
    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    private Long id;

    @Column(name = "NAME", nullable = false)
    private String name;

    @Column(name = "TYPENAME", nullable = false)
    private String typename;

    @Column(name = "MANUFACTURER", nullable = false)
    private String manufacturer;

    @ManyToOne()
    @JoinColumn(name = "OWNER_ID", nullable = true)
    private User owner;

    @Column(name = "VERSION", nullable = false, columnDefinition = "bigint default 0")
    @Version()
    private Long version;

    public Long getVersion() {
        return version;
    }

    public void setVersion(Long version) {
        this.version = version;
    }

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getTypename() {
        return typename;
    }

    public void setTypename(String typename) {
        this.typename = typename;
    }

    public String getManufacturer() {
        return manufacturer;
    }

    public void setManufacturer(String manufacturer) {
        this.manufacturer = manufacturer;
    }

    public User getOwner() {
        return owner;
    }

    public void setOwner(User owner) {
        this.owner = owner;
    }
}
